package com.rise.remi.controller;

import com.rise.remi.main.Main;
import com.rise.remi.player.Player;
import com.rise.remi.world.World;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
 *
 * @author remi
 */
public class Controller implements KeyListener {

    private boolean isChat;

    public Controller(boolean isChat) {
        this.isChat = isChat;
    }

    @Override
    public void keyTyped(KeyEvent ke) {
    }

    @Override
    public void keyPressed(KeyEvent ke) {
        Player player = Main.getCore().getPlayer();
        World world = Main.getCore().getWorld();

        //блокировка передвижения, пока не подключится клиент
        if (Main.getCore().isConnected()) {
            if (!isChat) {
                HeroController.heroController(player, world, ke);
            }
        }

        if (ke.getKeyCode() == KeyEvent.VK_ENTER) {
            Main.toggleChat();
        }

    }

    @Override
    public void keyReleased(KeyEvent ke) {
    }
}
